//
//  HHPTabBarViewController.m
//  HHPLiveVideo
//
//  Created by 韩红坡 on 2017/3/29.
//  Copyright © 2017年 韩红坡. All rights reserved.
//

#import "HHPTabBarViewController.h"
#import "HHPNavigationController.h"
#import "HHPMyCenterViewController.h"
#import "HHPHomeViewController.h"
#import "HHPVideoViewController.h"

@interface HHPTabBarViewController ()

@end

@implementation HHPTabBarViewController
+ (void)initialize
{
    NSDictionary *dict = @{
                           NSForegroundColorAttributeName:[UIColor grayColor]
                           };
    [[UITabBarItem appearance] setTitleTextAttributes:dict forState:UIControlStateNormal];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupViewControllers];
    
    self.view.backgroundColor = ViewBgColor;
    self.tabBar.translucent = NO;
//    self.tabBar.backgroundImage = [UIImage imageNamed:@"toolbar_bg"];
}

- (void)setupViewControllers {
    HHPHomeViewController *homeVC = [[HHPHomeViewController alloc] init];
    UINavigationController *homeViewController = [[HHPNavigationController alloc]
                                                      initWithRootViewController:homeVC];
    
    HHPVideoViewController *videoVC = [[HHPVideoViewController alloc] init];
    UINavigationController *videoViewController = [[HHPNavigationController alloc]
                                                       initWithRootViewController:videoVC];
    
    
    HHPMyCenterViewController *myCenterVC = [[HHPMyCenterViewController alloc] init];
    UINavigationController *myCenterViewController = [[HHPNavigationController alloc]
                                                          initWithRootViewController:myCenterVC];
    
    [self customizeTabBarForController];
    
    self.viewControllers = @[homeViewController, videoViewController, myCenterViewController];
}

/**
 在`-setViewControllers:`之前设置TabBar的属性，
 *
 */
- (void)customizeTabBarForController
{
    NSDictionary *dict1 = @{
                            CYLTabBarItemTitle : @"精彩",
                            CYLTabBarItemImage : @"toolbar_home",
                            CYLTabBarItemSelectedImage : @"toolbar_home_sel",
                            };
    NSDictionary *dict2 = @{
                            CYLTabBarItemTitle : @"视频",
                            CYLTabBarItemImage : @"toolbar_live",
                            CYLTabBarItemSelectedImage : @"toolbar_live_sel",
                            };
    NSDictionary *dict3 = @{
                            CYLTabBarItemTitle : @"我的",
                            CYLTabBarItemImage : @"toolbar_me",
                            CYLTabBarItemSelectedImage : @"toolbar_me_sel",
                            };
    
    self.tabBarItemsAttributes = @[dict1, dict2, dict3];
}

@end
